package main;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Toolkit;

import javax.swing.JFrame;

import parser.graph.SmartParserRunnable;
import smarties.info.panel.SmartInfoPanel;

import com.touchgraph.graphlayout.GLPanel;
import com.touchgraph.graphlayout.Node;

public class SmartGUI extends JFrame
{
	private static final long	serialVersionUID	= 3008539048482773110L;
	@SuppressWarnings("unchecked")
	private final GLPanel		panel;

	@SuppressWarnings("unchecked")
	public SmartGUI(String pathToData)
	{
		// XML
		Node.setNodeBackFixedColor(new Color(0.9f, 0.8f, 0.95f));
		Node.setNodeBackSelectColor(new Color(0.9f, 0.8f, 0.95f));
		Node.setNodeBorderMouseOverColor(new Color(0.9f, 0.8f, 0.95f, 0.5f));
		Node.setNodeMarkForRemovalColor(new Color(1f, 1f, 1f, 0));
		Node.setNodeJustMadeLocalColor(new Color(1f, 0, 0, 0.1f));

		this.getContentPane().setLayout(new BorderLayout());
		int width = 800;
		int height = 600;
		this.setSize(width, height);

		this.panel = new GLPanel();
		this.panel.setSize(width, height);
		this.panel.setPreferredSize(this.getSize());
		this.panel.initialize();

		this.getContentPane().add(this.panel, BorderLayout.CENTER);

		this.validate();
		this.setVisible(true);
		this.pack();

		Toolkit.getDefaultToolkit().setDynamicLayout(true);

		SmartInfoPanel smartInfoPanel = new SmartInfoPanel(this.panel);
		this.getContentPane().add(smartInfoPanel, BorderLayout.WEST);

		SmartParserRunnable parserRunnable = new SmartParserRunnable(
				pathToData, this.panel, this);
		Thread thread = new Thread(parserRunnable);
		thread.start();
	}

	public static void main(String[] args)
	{
		new SmartGUI(args[0]);
	}
}
